<?php

namespace App\Observers;


use App\Models\CheckOrder;
use App\Service\WxArticleData;

class CheckOrderObserver
{
    public function creating(CheckOrder $check_order)
    {
        //初始化检测订单阅读数
        $read_data = WxArticleData::get(($check_order->url));

        if ($read_data->code == 200) {
            $check_order->initialization_read_num =  $read_data->read_num;
        } else {
            throw new \Exception($read_data->msg);
        }
        return $check_order;
    }
}
